<?php
//抽象类  规定了方法 抽象类只能复写抽象方法之后才能使用此类
function write()
{
    //写入文件
}
abstract class ParamHandle
{
    protected $source;//源头 源文件
    protected $params = array();
    function __construct($source)
    {
        $this->source = $source;
    }
    function addParam($key, $val)
    {
        $this->params[$key] = $val;
    }
    function getAllParams()
    {
        return $this->params;
    }
    static function getInstance($filename)
    {
        if (preg_match("/\.xml$/i")) {
            return new XmlParamHandler($filename);
        }


        return new TextParamHandler($filename);
    }
    //  not defined function
    abstract function write();
    abstract function read();
}
class XmlParamHandle extends ParamHandle
{
    function read()
    {
        //读取xml内容
    }
    function write()
    {
        //读取xml内容 再返回给 $this->params
    }
}
class TextParamHandle extends ParamHandle
{
    function read()
    {
    }
    function write()
    {
    }
}

?>